const state = {
    isRange: false, // 是否启用测距模式
    lineArr: [],
    dotArr: [],
    polygonArr: [],
    distanceArr: [],
    divisionObj: {},
}

const mutations = {
    MAP_SETTING: (state, { key, val }) => {
        if (state.hasOwnProperty(key)) {
            state[key] = val
        }
    },
    ADD_LINES: (state, list) => {
        state.lineArr = list
    },
    ADD_DOTS: (state, list) => {
        state.dotArr = list
    },
    ADD_POLY: (state, arr) => {
        state.polygonArr = arr
    },
    ADD_DISTANCES: (state, list) => {
        state.distanceArr = list
    },
    ADD_DIVISION: (state, obj) => {
        state.divisionObj = obj
    }
}

const actions = {
    mapSetting({ commit }, data) {
        commit('MAP_SETTING', data)
    },
    addLines({ commit }, list) {
        commit('ADD_LINES', list)
    },
    addDots({ commit }, list) {
        commit('ADD_DOTS', list)
    },
    addPolygon({ commit }, arr) {
        commit('ADD_POLY', arr)
    },
    addDistances({ commit }, list) {
        commit('ADD_DISTANCES', list)
    },
    addDivision({ commit }, obj) {
        commit('ADD_DIVISION', obj)
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}